package cn.jinjimi.app.main.activity;

import android.app.Activity;
import android.content.Intent;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

import cn.jinjimi.app.R;
import cn.jinjimi.app.bean.QuesCode;
import cn.jinjimi.app.main.extend.ToolBarCommonActivity;
import cn.jinjimi.app.main.fragment.CompanyListFragment;

/**
 * Created by lforxeverc on 16/7/27.
 */
public class SetCompanyActivity extends ToolBarCommonActivity {
    public static final String TYPE_KEY = "typeKey";
    public static final String TYPE_COMPANY = "typeCompany";
    public static final int TYPE_UPLOAD_COMPANY = 0;
    public static final int TYPE_GET_COMPANY = 1;

    @Override
    protected void beforeInitView() {
        setContentView(R.layout.activity_set_company);
    }

    @Override
    protected void initial() {
        int type = getIntent().getIntExtra(TYPE_KEY, TYPE_UPLOAD_COMPANY);
        String name = getIntent().getStringExtra(TYPE_COMPANY);
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        ft.add(R.id.fragment_container, CompanyListFragment.newInstance(type, name));
        ft.commit();
    }

    /**
     * @param ctx
     * @param type TYPE_UPLOAD_COMPANY TYPE_GET_COMPANY
     */
    public static void launch(Activity ctx, int type) {
        Intent i = new Intent(ctx, SetCompanyActivity.class);
        i.putExtra(TYPE_KEY, type);
        if (type == TYPE_UPLOAD_COMPANY) {
            ctx.startActivityForResult(i, QuesCode.QuestCodeModifyInfo);
        } else {
            ctx.startActivityForResult(i, QuesCode.QuestCodeGetCompanyInfo);
        }

    }
}
